#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<string>
#include<iostream>

using namespace std;

int numDecodings(string s)
{
    int size = s.size();
    vector<int> dp(size);
    if (s[0] >= '1' && s[0] <= '9')
    {
        dp[0] = 1;
    }
    else
    {
        dp[0] = 0;
    }

    int a = s[1] - '0', b = s[0] - '0';
    if (dp[0] == 0)
    {
        dp[1] = 0;
    }
    else if (dp[0] == 1 && (b * 10 + a >= 10 && b * 10 + a <= 26))
    {
        dp[1] = 2;
    }
    else
    {
        dp[1] = 1;
    }

    for (int i = 2; i < size; i++)
    {
        a = s[i - 1] - '0';
        b = s[i - 2] - '0';
        if (s[i - 1] >= '1' && s[i - 1] <= '9')
        {
            dp[i] += dp[i - 1];
        }
        if (b * 10 + a >= 10 && b * 10 + a <= 26)
        {
            dp[i] += dp[i - 2];
        }
    }
    return dp[size - 1];
}

int main()
{
    string s = "226";
    cout << numDecodings(s) << endl;

	return 0;
}